<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Memcached UI</title>

    <link rel="stylesheet" href="/assets/lib/bootstrap/dist/css/bootstrap.min.css">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
  <div class="container">
    <nav class="navbar navbar-inverse">
      <div class="container-fluid">
        <div class="navbar-header">
          <a class="navbar-brand" href="/">Memcached UI</a>
        </div>
        <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
          <li><a href="/cluster">集群视图</a></li>
          <li class="active"><a href="/node">单机视图</a></li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
              当前服务器：{{.StatsInfo.InstanceID}} <span class="caret"></span>
              </a>
              <ul class="dropdown-menu">
                {{range $k := .Instances}}
                <li><a href="/node?instance={{$k}}">{{$k}}</a></li>
                {{end}}
              </ul>
            </li>
          </ul>
        </div>
      </div>
    </nav>
    {{if .HasInfoErr }}
    <div class="alert alert-danger" role="alert" style="text-align: center; font-size: 16px;">{{.InfoErr}}</div>
    {{end}}
    <div class="panel panel-primary">
      <div class="panel-heading">概况</div>
      <div class="panel-body">
        <div class="container-fluid">
          <div class="row">
            <div class="col-md-6"><label>服务器</label>：{{.StatsInfo.Source}}</div>
            <div class="col-md-6"><label>版本号</label>：{{.StatsInfo.Version}}</div>
          </div>
          <div class="row">
            <div class="col-md-6"><label>进程号</label>：{{.StatsInfo.Pid}}</div>
            <div class="col-md-6"><label>运行时长</label>：{{.StatsInfo.Uptime}}</div>
          </div>
          <div class="row">
            <div class="col-md-6"><label>可用最大内存</label>：{{.StatsInfo.MaxMemoryLimit}}</div>
            <div class="col-md-6"><label>内存占用</label>：{{.StatsInfo.CurrMemoryUsage}}</div>
          </div>
          <div class="row">
            <div class="col-md-6"><label>内容数</label>：{{.StatsInfo.CurrItems}}</div>
            <div class="col-md-6"><label>连接数</label>：{{.StatsInfo.CurrConnections}}</div>
          </div>
          <div class="row">
            <div class="col-md-6"><label>GET命中数</label>：{{.StatsInfo.GetHits}}</div>
            <div class="col-md-6"><label>GET未命中数</label>：{{.StatsInfo.GetMisses}}</div>
          </div>
          <div class="row">
            <div class="col-md-6"><label>GET命中率</label>：{{.StatsInfo.GetRate}}%</div>
            <div class="col-md-6"><label></label></div>
          </div>
        </div>
      </div>
    </div>
    <div class="panel panel-danger">
      <div class="panel-heading">操作</div>
      <div class="panel-body">
        <input type="hidden" value="{{.StatsInfo.InstanceID}}" id="target_instance"/>
        <!-- Nav tabs -->
        <ul class="nav nav-tabs" role="tablist">
          <li role="presentation" class="active"><a href="#action_get" role="tab" data-toggle="tab">Get</a></li>
          <li role="presentation"><a href="#action_set" role="tab" data-toggle="tab">Set</a></li>
          <li role="presentation"><a href="#action_delete" role="tab" data-toggle="tab">Delete</a></li>
          <li role="presentation"><a href="#action_flushall" role="tab" data-toggle="tab">FlushAll</a></li>
        </ul>
        <!-- Tab panes -->
        <div class="tab-content">
          <div role="tabpanel" class="tab-pane active" id="action_get">
            <form class="form-inline" style="margin-top: 10px;">
              <div class="form-group">
                <label>键</label>：<input type="text" name="get_key" class="form-control" v-model="k">
              </div>
              <button class="btn btn-default" v-on="click: getIt">查询</button>
            </form>
          </div>
          <div role="tabpanel" class="tab-pane" id="action_set">
            <form class="form-inline" style="margin-top: 10px;">
              <div class="form-group">
                <label>键</label>：<input type="text" name="set_key" class="form-control" v-model="k">
                <label>值</label>：<textarea name="set_value" class="form-control" rows="1" v-model="v"></textarea>
                <label>有效期</label>：<input type="number" name="set_exptime" class="form-control" v-model="expTime">
              </div>
              <button class="btn btn-default" v-on="click: setIt">提交</button>
            </form>
          </div>
          <div role="tabpanel" class="tab-pane" id="action_delete">
            <form class="form-inline" style="margin-top: 10px;">
              <div class="form-group">
                <label>键</label>：<input type="text" name="delete_key" class="form-control" v-model="k">
              </div>
              <button class="btn btn-default" v-on="click: deleteIt">确定</button>
            </form>
          </div>
          <div role="tabpanel" class="tab-pane" id="action_flushall">
            <button class="btn btn-default" style="margin-top: 10px;" v-on="click: flushIt">确定清空</button>
          </div>
      </div>
    </div>
  </div>
  <div id="action_result"></div>
</div>
<script src="/assets/lib/jquery/dist/jquery.min.js"></script>
<script src="/assets/lib/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="/assets/lib/vue/dist/vue.min.js"></script>
<script src="/assets/index.js"></script>
</body>
</html>
